package cn.kgc.ssm.web.controller;

import cn.kgc.ssm.web.annotations.Logs;
import cn.kgc.ssm.web.entity.Active;
import cn.kgc.ssm.web.enums.Operations;
import cn.kgc.ssm.web.response.ResponseResult;
import cn.kgc.ssm.web.service.ActiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 课工场
 * @date 2024/8/5
 * @description 活动模块
 */
@RestController
@RequestMapping("active")
public class ActiveController {

    @Autowired
    private ActiveService activeService;

    //  活动信息分页
    @GetMapping("page")
    public ResponseResult activePage(Integer page,Integer limit,String publisher) {
        return activeService.activePage(page,limit,publisher);
    }

    // 前端页面活动列表
    @GetMapping("/font/list/{limit}")
    public ResponseResult activeList(@PathVariable("limit") Integer limit) {
        return activeService.activeList(limit);
    }

    // 发布活动
    @Logs(operation = Operations.ADD,model = "活动模块")
    @PostMapping("add")
    public ResponseResult  publishActive(@RequestBody Active active){

      return   activeService.publishActive(active);
    }

    // 更新活动
    @Logs(operation = Operations.UPDATE,model = "活动模块")
    @PostMapping("edit")
    public ResponseResult  editActive(@RequestBody Active active){
        return   activeService.editActive(active);
    }

    // 删除活动
    @Logs(operation = Operations.DELETE,model = "活动模块")
    @PostMapping("delete")
    public ResponseResult  deleteActive(@RequestBody List<Integer> ids){
        return   activeService.deleteActive(ids);
    }

}
